# Maintainer: Celeste <cielesti@protonmail.com>
maintainer="Celeste <cielesti@protonmail.com>"
pkgname=ocaml-tsdl-ttf
pkgver=0.6
pkgrel=0
_pkgreal=tsdl-ttf
pkgdesc="SDL2_Ttf bindings to go with ocaml-tsdl"
url="https://github.com/sanette/tsdl-ttf"
arch="all !riscv64 !loongarch64" # ocaml
license="BSD-3-Clause"
depends_dev="
	$pkgname=$pkgver-r$pkgrel
	ocaml-ctypes-dev
	ocaml-tsdl-dev
	sdl2_ttf-dev
	"
makedepends="
	$depends_dev
	dune
	dune-configurator
	ocaml
	"
checkdepends="
	libffi-dev
	ocaml-bigarray-compat-dev
	ocaml-integers-dev
	"
subpackages="$pkgname-dev"
source="$_pkgreal-$pkgver.tar.gz::https://github.com/sanette/tsdl-ttf/archive/$pkgver.tar.gz"
builddir="$srcdir/$_pkgreal-$pkgver"

# 32-bit archs
case "$CARCH" in
	arm*|x86) options="$options textrels" ;;
esac

build() {
	dune build --release --verbose
}

check() {
	dune runtest --build-dir=.testenv --verbose
}

package() {
	dune install --destdir="$pkgdir" --docdir=/.omit
}

dev() {
	default_dev

	cd "$pkgdir"

	local path; find usr/lib/ocaml \( \
			-name '*.cmt' -o \
			-name '*.cmti' -o \
			-name '*.ml' -o \
			-name '*.mli' \
		\) | while read -r path
	do
		amove "$path"
	done
}

prepare_py_provides() {
	local datadir="${subpkgdir:-$pkgdir}"
	local pkgbasedir=${pkgbasedir:-"$startdir/pkg"}
	local controldir="$pkgbasedir"/.control.${subpkgname:-$pkgname}

	options_has "!tracedeps" && return 0

	ocaml4-abuild-find provides \
		"$datadir"/usr/lib/ocaml \
		"$controldir" \
		"$pkgver-r$pkgrel"
}

scan_python3_dependency() {
	local controldir="$2" datadir="$3"

	ocaml4-abuild-find requires \
		"$datadir"/usr/lib/ocaml \
		"$controldir"
}

sha512sums="
3184207a273869db6c208b37e41d09121ec124fdab6675d5c2fcbe2592f0104d2bfd8afeeee2b7c6ac12d94ec9bdf89d8bb2f581e3ac2767a5c95814dbbe7db3  tsdl-ttf-0.6.tar.gz
"
